package com.pearadmin.common.nucleus.domain.response;


import com.pearadmin.common.constant.ResultContsant;
import lombok.Data;
import java.io.Serializable;

@Data
public class Result implements Serializable {

    // 响应状态码
    private Integer code;
    // 提示消息
    private String msg;
    // 携带数据
    private Object data;

    /**
     * @describe: 返回警告消息
     * @return Result
     * */
    public static Result warming(String msg){
        Result result = new Result();
        result.setCode(ResultContsant.WARMING_CODE);
        result.setMsg(msg);
        return result;
    }


    /**
     * @describe: 成功默认处理
     * @return Result
     * */
    public static Result success(){
        Result result = new Result();
        result.setCode(ResultContsant.SUCCESS_CODE);
        result.setMsg(ResultContsant.SUCCESS_MSG);
        return result;
    }

    /**
     * @describe 成功消息,携带自定义消息
     * @param  msg
     * @return Result
     * */
    public static Result success(String msg){
        Result result = new Result();
        result.setCode(ResultContsant.SUCCESS_CODE);
        result.setMsg(msg);
        return result;
    }

    /**
     * @describe 成功消息,携带自定义状态码和提示
     * @param code msg
     * @return Result
     * */
    public static Result success(Integer code,String msg){
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    /**
     * @describe 成功消息,携带默认状态码 和 提示 携带数据
     * @param data
     * @return Result
     * */
    public static Result success(Object data){
        Result result = new Result();
        result.setCode(ResultContsant.SUCCESS_CODE);
        result.setMsg(ResultContsant.SUCCESS_MSG);
        result.setData(data);
        return result;
    }

    /**
     * @describe: 失败默认处理
     * @return Result
     * */
    public static Result failure(){
        Result result = new Result();
        result.setCode(ResultContsant.FAILURE_CODE);
        result.setMsg(ResultContsant.FAILURE_MSG);
        return result;
    }

    /**
     * @describe 失败消息,携带自定义状态码和提示
     * @param  msg
     * @return Result
     * */
    public static Result failure(String msg){
        Result result = new  Result();
        result.setMsg(msg);
        result.setCode(ResultContsant.FAILURE_CODE);
        return result;
    }

    /**
     * @describe 失败消息,携带自定义状态码和提示
     * @param code msg
     * @return Result
     * */
    public static Result failure(Integer code,String msg){
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

}
